package com.study.d024chart;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.BubbleChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**Chart接口 ,   XYChart 子接口 的实现类BubbleChart
 * BubbleChart 气泡图的使用
 * 气泡图的 x,y轴 都是Number类型
*@description
*@author xtayhame
*date 2020年3月18日
*version
*since v1.0
*/
public class BubbleChartMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		HBox hBox = new HBox(10);

		BubbleChart<Number, Number> lineChart3 = getView3();
		hBox.getChildren().addAll(lineChart3);
		anchorPane.getChildren().add(hBox);
		stage.setScene(new Scene(anchorPane, 900, 500));
		stage.show();
	}



	//x,y轴都是数字
	public BubbleChart<Number, Number> getView3(){
		NumberAxis  x = new NumberAxis();
		x.setLabel("月份");

		NumberAxis  y = new NumberAxis();
		y.setLabel("产量");

		ObservableList<XYChart.Series<Number,Number>> datas = FXCollections.observableArrayList();

		XYChart.Series<Number, Number> xy1 = new XYChart.Series<Number, Number>();
		ObservableList<Data<Number, Number>> data1 = FXCollections.observableArrayList();
		Data<Number, Number> d1 = new Data<Number, Number>(10,23);
		Data<Number, Number> d2 = new Data<Number, Number>(20,43);
		Data<Number, Number> d3 = new Data<Number, Number>(30,53);
		data1.addAll(d1,d2,d3);
		xy1.setData(data1);
		xy1.setName("生产线一");

		//设置后可以使该点的圆圈变大， 该方法在每种类型图标中的作用是不一样的
		//d1.setExtraValue(23);

		XYChart.Series<Number, Number> xy2 = new XYChart.Series<Number, Number>();
		ObservableList<Data<Number, Number>> data2 = FXCollections.observableArrayList();
		Data<Number, Number> d4 = new Data<Number, Number>(10,83);
		Data<Number, Number> d5 = new Data<Number, Number>(20,51);
		Data<Number, Number> d6 = new Data<Number, Number>(30,29);
		data2.addAll(d4,d5,d6);
		xy2.setData(data2);
		xy2.setName("生产线二");


		datas.add(xy1);
		datas.add(xy2);

		BubbleChart<Number,Number> lineChart=new BubbleChart(x, y);
		lineChart.setData(datas);

		lineChart.setTitle("全年产量表三");
		return lineChart;
	}


}
